﻿namespace GreenIsomer.Web.Controls.JQuery {
	using System;
	using System.Web.UI;

	/// <summary>
	/// Defines jGrowl options that can logically be overriden per message rather than just globally.
	/// </summary>
	public class JGrowlOptions {


		#region Members

		private int? life;

		#endregion


		#region Constructors

		/// <summary>
		/// Initializes a new instance of the GreenIsomer.Web.Controls.JQuery.JGrowlOptions class.
		/// </summary>
		public JGrowlOptions() { }

		#endregion


		#region Properties: Initialization options

		/// <summary>
		/// Gets or sets an optional header to prefix the message.  This is often helpful for associating messages to each other.
		/// This value overrides the GreenIsomer.Web.Controls.JQuery.JGrowl property.  A value of null will fall back to the control's value.
		/// </summary>
		public virtual string Header { get; set; }

		/// <summary>
		/// Gets or sets whether a message will stick to the screen until it is intentionally closed by the user.
		/// This value overrides the GreenIsomer.Web.Controls.JQuery.JGrowl property.  A value of null will fall back to the control's value.
		/// </summary>
		public virtual bool? Sticky { get; set; }

		/// <summary>
		/// Gets or sets a CSS class designating custom styling for this particular message.
		/// This value should be managed by the website project, as jGrowl does not fully support the jQuery UI theme framework.
		/// This value overrides the GreenIsomer.Web.Controls.JQuery.JGrowl property.  A value of null will fall back to the control's value.
		/// </summary>
		[CssClassProperty]
		public virtual string Theme { get; set; }

		/// <summary>
		/// Gets or sets the lifespan (in milliseconds) of a non-sticky message on the screen.
		/// This value overrides the GreenIsomer.Web.Controls.JQuery.JGrowl property.  A value of null will fall back to the control's value.
		/// </summary>
		/// <exception cref="ArgumentOutOfRangeException">Value must be greater than zero.</exception>
		public virtual int? Life {
			get { return life; }
			set {
				if(value.HasValue && value.Value <= 0) throw new ArgumentOutOfRangeException("value", "Value must be greater than zero.");

				life = value;
			}
		}

		#endregion


	}

}